package myapp.my01

import android.os.Bundle

import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugin.common.MethodChannel

class MainActivity(): FlutterActivity() {
  private val CHANNEL = "samples.flutter.io/battery"
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)
    MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->
      // TODO
      val batteryLevel = getBatteryLevel()
      if (call.method == "getBatteryLevel") {
        result.success(batteryLevel)
      }else{
        result.notImplemented();
      }
    }
  }

  private fun getBatteryLevel(): String {
    val batteryLevel: String
    // batteryLevel=
    return "点击一下生成新的内容字符串"
  }
}
